import { userInfoService } from '@/api/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'
// token
export const useUserStore = defineStore(
	'big-user',
	() => {
		const user = ref({})
		const token = ref('')
		const setToken = t => {
			token.value = t
		}
		const removeToken = () => {
			token.value = ''
		}
		const getUser = async () => {
			const res = await userInfoService()
			console.log(res.data.data)
			user.value = res.data.data
		}
		const setUser = obj => (user.value = obj)
		return {
			token,
			setToken,
			removeToken,
			user,
			getUser,
			setUser
		}
	},
	{
		persist: true
	}
)
